import 'package:flutter/material.dart';

class Widget_Switch_Page extends StatefulWidget {

  @override
  State<StatefulWidget> createState() {
    return Widget_Switch_State();
  }
}

class Widget_Switch_State extends State<Widget_Switch_Page> {
  bool isCheck = false;
  bool isCheck1 = false;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("Switch"),
        ),
        body: Column(
          children: <Widget>[
            Switch(
              value: isCheck,
              onChanged: (isChecked) {
                setState(() {
                  isCheck = isChecked;
                });
              },

              activeColor: Colors.black,
              activeTrackColor: Colors.blue,
//
              inactiveThumbColor: Colors.green,
              inactiveTrackColor: Colors.orange,

//              activeThumbImage: AssetImage("images/app.png"),
//              inactiveThumbImage: AssetImage("images/app.png"),

              materialTapTargetSize: MaterialTapTargetSize.padded,
            ),
            Container(
              color: Colors.grey,
              child: SwitchListTile(
                value: isCheck1,
                onChanged: (isChecked) {
                  setState(() {
                    isCheck1 = isChecked;
                  });
                },
                activeColor: Colors.red,
                title: Text("标题"),
                subtitle: Text("副标题副标题副标题副标题副标题副标题副标题副标题副标题"),
                secondary: Icon(Icons.alarm),
                selected: true,
                activeThumbImage: AssetImage("images/app.png"),
                inactiveThumbImage: AssetImage("images/app.png"),
                isThreeLine: false,
              ),
            ),
            Container(
              margin: EdgeInsets.only(top: 5.0),
              color: Colors.grey,
              child: SwitchListTile(
                value: isCheck1,
                onChanged: (isChecked) {
                  setState(() {
                    isCheck1 = isChecked;
                  });
                },
                activeColor: Colors.red,
                title: Text("标题"),
                subtitle: Text("副标题副标题副"),
                secondary: Icon(Icons.alarm),
                selected: true,
                activeThumbImage: AssetImage("images/app.png"),
                inactiveThumbImage: AssetImage("images/app.png"),
                isThreeLine: true,
              ),
            )
          ],
        ),
      ),
    );
  }
}

/**
 *
 *
    const Switch({
    Key key,
    @required this.value,
    @required this.onChanged,
    this.activeColor,//选中时圆圈的颜色
    this.activeTrackColor,//选中时底部横条的颜色

    this.inactiveThumbColor,//未选中时圆圈的颜色
    this.inactiveTrackColor,//未选中时底部横条的颜色

    this.activeThumbImage,//选中时圆圈的图片
    this.inactiveThumbImage,//未选中时圆圈的图片

    this.materialTapTargetSize,//点击区域尺寸，padded：向四周扩展48px区域;shrinkWrap：控件区域
    this.dragStartBehavior = DragStartBehavior.start,
    })
 */

/**
 * const SwitchListTile({
    Key key,
    @required this.value,
    @required this.onChanged,
    this.activeColor,
    this.activeTrackColor,
    this.inactiveThumbColor,
    this.inactiveTrackColor,
    this.activeThumbImage,
    this.inactiveThumbImage,
    this.title,
    this.subtitle,
    this.isThreeLine = false,//设置为true，高度变大
    this.dense,
    this.secondary,//左侧图标
    this.selected = false,
    })
 */

